import {
	api_getProductAll
} from '../../api/api.product.js'
export default{
	namespaced: true,
	state:{
		productList:[]
	},
	mutations:{
		SET_PRODUCT_LIST(state,data){
			state.productList=data
		}
	},
	actions:{
		GET_PRODUCT_LIST({state,commit}){
			return new Promise((resolve, reject) =>{
				api_getProductAll()
					.then((res)=>{
						if(res.body){
							let body=res.body
							commit('SET_PRODUCT_LIST',body)
							resolve(body)
						}else{
							commit('SET_PRODUCT_LIST',[])
							reject()
						}
						
					})
					.catch(()=>{
						commit('SET_PRODUCT_LIST',[])
						reject()
					})
			})
		}
	}
}